package com.example.demo.job;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Role;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
import org.springframework.scheduling.config.ScheduledTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

import java.lang.reflect.Method;
import java.util.Set;

/**
 * @author: twd
 * @since: 2023/7/24 10:22
 */
@Component
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class ScheduledAnnProcesser extends ScheduledAnnotationBeanPostProcessor {
    public ScheduledAnnProcesser() {
        super();
    }

    public ScheduledAnnProcesser(ScheduledTaskRegistrar registrar) {
        super(registrar);
    }

    @Override
    public int getOrder() {
        return super.getOrder();
    }

    @Override
    public void setScheduler(Object scheduler) {
        super.setScheduler(scheduler);
    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver resolver) {
        super.setEmbeddedValueResolver(resolver);
    }

    @Override
    public void setBeanName(String beanName) {
        super.setBeanName(beanName);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        super.setBeanFactory(beanFactory);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        super.setApplicationContext(applicationContext);
    }

    @Override
    public void afterSingletonsInstantiated() {
        super.afterSingletonsInstantiated();
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        super.onApplicationEvent(event);
    }

    @Override
    public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
        super.postProcessMergedBeanDefinition(beanDefinition, beanType, beanName);
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        return super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        if(true){
            return bean;
        }
        return super.postProcessAfterInitialization(bean,beanName);
    }

    @Override
    protected void processScheduled(Scheduled scheduled, Method method, Object bean) {
        super.processScheduled(scheduled, method, bean);
    }

    @Override
    protected Runnable createRunnable(Object target, Method method) {
        return super.createRunnable(target, method);
    }

    @Override
    public Set<ScheduledTask> getScheduledTasks() {
        return super.getScheduledTasks();
    }

    @Override
    public void postProcessBeforeDestruction(Object bean, String beanName) {
        super.postProcessBeforeDestruction(bean, beanName);
    }

    @Override
    public boolean requiresDestruction(Object bean) {
        return super.requiresDestruction(bean);
    }

    @Override
    public void destroy() {
        super.destroy();
    }
}
